//   acwing 4262   https://www.acwing.com/problem/content/4265/



#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100010;

int n;
int b[N];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        b[i] -= x;
    }

    for (int i = n + 1; i; i--) b[i] -= b[i - 1];

    int r = 0;

    for (int i = 1; i <= n + 1; i++)   if (b[i] > 0) r += b[i];

    cout << r;

    return 0;
}